<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>全品类禁用字</title>
        <link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/public.css">
        <script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>
        <script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="/webapp/js/lib/jquery.global.settings.js"></script>
        <script type="text/javascript" src="/webapp/js/lib/ajaxfileupload.js"></script>
        <script type="text/javascript" src="/webapp/js/common/config.js"></script>
    </head>
    <body>
        <div class="easyui-container-fluid">
            <div class="easyui-panel" style="border: none;">
                <div class="nav" id="nav"></div>
                <div class="easyui-panel" style="border:none;">
                    <a href="javascript:void(0);" class="easyui-linkbutton c8" style="width:80px;margin-left: 40px;" onclick="searchBy()">查询</a>
                    <br>
                    <br>
                    <label class="item-label">禁用字：</label>
                    <input class="easyui-textbox" style="width:500px;height: 50px" type="text" id="words"/>
                    <a href="javascript:void(0);" class="easyui-linkbutton c6" style="width:80px;margin-left: 40px;" onclick="addDisableWords()">添加</a>

                </div>
            </div>
        </div>
        <br>
        <dev id="disableWordsSize" style="margin-left: 40px;"></dev>
        个禁用字：

        <br>
        <!--<dev id="disableWords"></dev>-->
        &nbsp;&nbsp;&nbsp;<input id="disableWords" class="easyui-tagbox" value="" style="width:1444px;min-height:80px;" data-options="multiline:true,editable:false"/>
        <a href="javascript:void(0);" class="easyui-linkbutton c6" style="width:80px;margin-left: 40px;" onclick="save()">保存</a>
        <div style="margin-bottom:20px;">
            &nbsp;&nbsp;&nbsp;<label class="item-label">天猫禁用字：</label>
        </div>

        <div style="margin-bottom:20px;">
            &nbsp;&nbsp;&nbsp;<input id="tmDisable" class="easyui-tagbox" value="" style="width:1444px;min-height:80px;" data-options="multiline:true"/>
            <a href="javascript:void(0);" class="easyui-linkbutton c6" style="width:80px;margin-left: 40px;" onclick="saveTM()">保存</a>
        </div>
    </body>
    <script type="text/javascript">
        setNav();
        searchBy();
        aRecords("全品类禁用字","/webapp/pages/product/category/disableWords")
        function addDisableWords() {
            var content = $("#words").textbox("getValue");
            $.messager.confirm("提示", "您确定要添加禁用字么吗?", function (r) {
                if (r) {
                    $.ajax({
                        url: config.url + "/category/addDisableWords",
                        type: "POST",
                        data: {content: content},
                        dataType: 'json',
                        xhrFields: {withCredentials: true},
                        beforeSend: function () {
                            $.messager.progress({
                                title: "请稍等",
                                interval: 50,
                                text: "操作进行中..."
                            });
                        },
                        complete: function () {
                            $.messager.progress("close");
                        },
                        success: function (data) {
                            if (data.code == 200) {
                                $("#words").textbox("setValue", "");
                                $.messager.show({
                                    title: '提示',
                                    msg: data.msg,
                                    timeout: 1000,
                                    showType: 'slide'
                                });
                                searchBy();
                            } else {
                                $.messager.alert("提示", data.msg, "error");
                            }
                        },
                        error: function () {
                        }
                    });
                }
            });
        }

        function searchBy() {
            $.ajax({
                url: config.url + "/category/getDisableWords",
                type: 'get',
                dataType: 'json',
                xhrFields: {withCredentials: true},
                beforeSend: function () {
                    $.messager.progress({
                        title: "请稍等",
                        interval: 40,
                        text: "数据加载中..."
                    });
                },
                complete: function () {
                    $.messager.progress("close");
                },
                success: function (data) {
                    if (data.code == 200) {
                        $("#disableWordsSize").text('共'+data.msg.count);
                        $("#disableWords").tagbox("setValue","");
                        $("#disableWords").tagbox("setValue",data.msg.content.sort());
                        $("#tmDisable").tagbox("setValue","");
                        $("#tmDisable").tagbox("setValue",data.msg.tmContent.sort());
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {

                }
            });
        }

        function save() {
            var disableWords = $("#disableWords").tagbox("getValues");
            var content = "";
            for (const d of disableWords) {
                content += d + ",";
            }
            $.messager.confirm("提示", "您确定要修改禁用字么吗?", function (r) {
                if (r) {
                    $.ajax({
                        url: config.url + "/category/updateDisableWords",
                        type: "POST",
                        data: {content: content},
                        dataType: 'json',
                        xhrFields: {withCredentials: true},
                        beforeSend: function () {
                            $.messager.progress({
                                title: "请稍等",
                                interval: 50,
                                text: "操作进行中..."
                            });
                        },
                        complete: function () {
                            $.messager.progress("close");
                        },
                        success: function (data) {
                            if (data.code == 200) {
                                $("#words").textbox("setValue", "");
                                $.messager.show({
                                    title: '提示',
                                    msg: data.msg,
                                    timeout: 1000,
                                    showType: 'slide'
                                });
                                searchBy();
                            } else {
                                $.messager.alert("提示", data.msg, "error");
                            }
                        },
                        error: function () {
                        }
                    });
                }
            });
        }
        function saveTM() {
            var tmDisable = $("#tmDisable").tagbox("getValues");
            var content = "";
            for (const d of tmDisable) {
                content += d + ",";
            }
            $.messager.confirm("提示", "您确定要修改天猫禁用字么吗?", function (r) {
                if (r) {
                    $.ajax({
                        url: config.url + "/category/updateDisableWords",
                        type: "POST",
                        data: {content: content,lb:"tm"},
                        dataType: 'json',
                        xhrFields: {withCredentials: true},
                        beforeSend: function () {
                            $.messager.progress({
                                title: "请稍等",
                                interval: 50,
                                text: "操作进行中..."
                            });
                        },
                        complete: function () {
                            $.messager.progress("close");
                        },
                        success: function (data) {
                            if (data.code == 200) {
                                $.messager.show({
                                    title: '提示',
                                    msg: data.msg,
                                    timeout: 1000,
                                    showType: 'slide'
                                });
                                searchBy();
                            } else {
                                $.messager.alert("提示", data.msg, "error");
                            }
                        },
                        error: function () {
                        }
                    });
                }
            });
        }

    </script>
</html>